<?php
$this->breadcrumbs=array(
	'Desafios'=>array('index'),
	$model->name,
);

$this->menu=array(
		array('label'=>'Responder Desafio','url'=>array('update','id'=>$model->id), 'visible'=>$this->verifyAnswer($model)),
);


function getUserLayout($user, $type) {
	return '<td class="column" style="background:#F6FCFA; border-radius:5px; padding: 5px; text-align: center;">'
	  .CHtml::image(Utils::findImageUrl($user->photo),$user->name,array('width'=>50,'height'=>50))
	  .'<p style="text-align: center;">'.$user->username
	  .'<br/><b>'.$type.'</b></p>'
	  .'<td>';
}

?>
<h3 align="center">Desafio: <?php echo $model->name ?></h3>
<b>Participantes do Desafio:</b>
<div class="ui-widget-content" style="overflow: auto; style="border-radius:5px; background:#eeeeee; padding:10px;">
<table>
<tr>
<!-- Desafiante -->
<?php $users = array();?>

<?php echo getUserLayout($model->challenger, 'Desafiante'); $users[] = $model->challenger;?>

<!-- Mediador -->
<?php echo getUserLayout($model->mediator, 'Mediador'); $users[] = $model->mediator;?>

<?php foreach($model->challengeHasProposals as $challengeHasProposal) { ?>
	<!-- Desafiado -->
	<?php if(!in_array($challengeHasProposal->challenged, $users)) { ?>
	<?php echo getUserLayout($challengeHasProposal->challenged, 'Desafiado'); $users[] = $challengeHasProposal->challenged;?>
<?php }}?>
<tr>
</table>
</div>
 
<?php foreach($model->challengeHasProposals as $challengeHasProposal) {
	$this->showAnswer($challengeHasProposal);
 } ?>
